/*
 * CommonTypes.h
 *
 *  Created on: May 1, 2013
 *      Author: dsweeney
 */

#ifndef COMMONTYPESLIB_H_
#define COMMONTYPESLIB_H_

#include <climits>

namespace CommonLibTypes
{
	#define SUCCESS SHRT_MAX;
	#define FAIL SHRT_MIN;
	typedef char byte;
	typedef unsigned short nodeId_t;
	typedef void (*functPtr_t)(void);

	//*************************************************************************
	//	packet structure
	//*************************************************************************
	enum packetType_t {NiB, DATA, SYNC};
	enum slot_state_t {TX, RX, COLLISION, CLEAR};

	const byte MAX_DATA = 100;

	typedef struct miheader_t
	{
		CommonLibTypes::byte data [CommonLibTypes::MAX_DATA];
		CommonLibTypes::byte addr [4];
		CommonLibTypes::byte subnet [4];
	}miheader_t;

	typedef struct macheader_t
	{
		CommonLibTypes::miheader_t miheader;
		CommonLibTypes::nodeId_t nodeId;
	}macheader_t;

	typedef struct phyheader_t
	{
		CommonLibTypes::macheader_t macheader;
		int slotNum;
		int txPower;
	}phyheader_t;

	typedef struct packet_t
	{
		CommonLibTypes::phyheader_t phyheader;
	}packet_t;

//*****************************************************************************
//	message structure
//*****************************************************************************
	enum units {};
	enum intraProcessMessageType_t {};

	typedef struct messageHeader_t
	{
		CommonLibTypes::units destination;
		CommonLibTypes::units source;
		CommonLibTypes::intraProcessMessageType_t messageType;
	}messageHeader_t;

	typedef struct intraProcessMessage_t
	{
		CommonLibTypes::messageHeader_t messageHeader;
		void* message;
	}intraProcessMessage_t;

}
#endif /* COMMONTYPES_H_ */
